package my.fuelwallet.test;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class IconListAdapter extends ArrayAdapter<String> {

	private static final String tag = "IconListAdapter";
	//private static final String ASSETS_DIR = "images/";
	private Context context;

	private ImageView IconItemIcon;
	private TextView IconItemName;
	//private TextView IconItemAbbrev;
	//private List<IconItem> iconitems = new ArrayList<IconItem>();
	private List<String> iconitems = new ArrayList<String>();

	public IconListAdapter(Context context, int textViewResourceId,
			List<String> objects) {
		super(context, textViewResourceId, objects);
		this.context = context;
		this.iconitems = objects;
	}

	public int getCount() {
		return this.iconitems.size();
	}

	public String getItem(int index) {
		return this.iconitems.get(index);
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		View row = convertView;
		if (row == null) {
			// ROW INFLATION
			Log.d(tag, "Starting XML Row Inflation ... ");
			LayoutInflater inflater = (LayoutInflater) this.getContext()
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			row = inflater.inflate(R.layout.icon_listitem, parent, false);
			Log.d(tag, "Successfully completed XML Row Inflation!");
		}

		// Get item
		String icon_item = getItem(position);
		IconItemIcon = (ImageView) row.findViewById(R.id.item_icon);
		IconItemName = (TextView) row.findViewById(R.id.item_name);
		//IconItemAbbrev = (TextView) row.findViewById(R.id.IconItem_abbrev);

		IconItemName.setText(icon_item);
		if(icon_item.equals("Account Manager")){
			IconItemIcon.setImageResource(R.drawable.newaccount);
		}else if(icon_item.equals("Update prices")){
			IconItemIcon.setImageResource(R.drawable.update);
		}else if(icon_item.equals("Price list")){
			IconItemIcon.setImageResource(R.drawable.list);
		}else if(icon_item.equals("History")){
			IconItemIcon.setImageResource(R.drawable.history);
		}
		

		return row;
	}

}